package cmd

import (
	"fmt"
	"strconv"

	"github.com/spf13/cobra"

	"lwa-go/services"
)

var fixChapterCommand = &cobra.Command{
	Use:   "fix-chapter",
	Short: "fix chapter error string",
	Long:  "fix chapter error string",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 3 {
			fmt.Println("缺少参数")
			return
		}
		novelIdString := args[0]
		novelId, _ := strconv.Atoi(novelIdString)
		errorString := args[1]
		replaceString := args[2]
		chapterService := services.ChapterService{}
		chapterService.FixErrorStringRows(novelId, errorString, replaceString)
	},
}

func init() {
	rootCmd.AddCommand(fixChapterCommand)
}
